package com.mallcloud.mall.app.controller;

import cn.hutool.core.lang.tree.Tree;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.mallcloud.mall.app.service.AppBrandService;
import com.mallcloud.mall.common.core.util.R;
import com.mallcloud.mall.product.api.entity.BrandModel;
import com.mallcloud.mall.product.service.BrandService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "品牌信息管理")
@RestController
@RequiredArgsConstructor
@RequestMapping("/app/product/brand")
public class AppBrandController {
    private final AppBrandService appBrandService;
    private final BrandService brandService;

    @ApiOperation("品牌导览")
    @GetMapping("/treeByName")
    public R<List<Tree<Long>>> tree(String name){
        return R.ok(appBrandService.treeByName(name));
    }

    @ApiOperation("通过id查询")
    @GetMapping("/getInfo")
    public R<BrandModel> getInfo(BrandModel dto) {
        return R.ok(brandService.getById(dto.getBrandId()));
    }

}
